<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        ul {
            display: flex;

            li {
                list-style: none;
                padding: 10px 15px;
                color: blue;
            }

            .active {
                background-color: pink;
            }
        }
    </style>
</head>

<body>
    <h1>导航栏</h1>
    <hr>
    <div id="box">
        <ul>
            <li :class="isOk1?'':'active'" @click="tab1">首页</li>
            <li :class="isOk2?'':'active'" @click="tab2">关于我们</li>
            <li :class="isOk3?'':'active'" @click="tab3">联系我们</li>
        </ul>
    </div>
    <script src="../vue.js"></script>
    <script>
        let box = new Vue({
            el: '#box',
            data: {
                isOk1: false,
                isOk2: true,
                isOk3: true
            },
            methods: {
                tab1() {
                    this.isOk1 = false;
                    this.isOk2 = true;
                    this.isOk3 = true;
                },
                tab2() {
                    this.isOk1 = true;
                    this.isOk2 = false;
                    this.isOk3 = true;
                },
                tab3() {
                    this.isOk1 = true;
                    this.isOk2 = true;
                    this.isOk3 = false;
                },
                
            }
        })
    </script>
</body>

</html>